package com.chat.common.vo;

import com.chat.common.dto.MessageDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wei kunJie
 * @date 2024/4/21 16:21:27
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MessageVO {
    private Long id;

    private String time;

    private List<MsgContentItem> contentItemList;

    private String fromUserAccount;

    private String fromUserName;

    private String fromUserAvatar;

    private Boolean isGroup;
    private String groupAccount;
    private Long timeMillis;

    public MessageVO(String userAccount,MessageDTO messageDTO){
        id= messageDTO.getId();
        time=messageDTO.getTime();
        contentItemList=new ArrayList<>(messageDTO.getContentItemList());
        fromUserAccount=userAccount;
        fromUserAvatar=messageDTO.getUserAvatar();
        fromUserName=messageDTO.getUserName();
        isGroup=messageDTO.getIsGroup();
    }

    public MessageVO(Long timeMillis,String userAccount,String groupAccount,MessageDTO messageDTO){
        id= messageDTO.getId();
        time=messageDTO.getTime();
        contentItemList=new ArrayList<>(messageDTO.getContentItemList());
        fromUserAccount=userAccount;
        fromUserAvatar=messageDTO.getUserAvatar();
        fromUserName=messageDTO.getUserName();
        isGroup=messageDTO.getIsGroup();
        this.timeMillis= timeMillis;
        this.groupAccount=groupAccount;
    }
}
